package io.renren.modules.category.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.renren.common.service.impl.CrudServiceImpl;
import io.renren.common.utils.ConvertUtils;
import io.renren.modules.category.dao.TConsumerDao;
import io.renren.modules.category.dto.TConsumerDTO;
import io.renren.modules.category.entity.TConsumerEntity;
import io.renren.modules.category.service.TConsumerService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import java.util.Objects;

/**
 * 消费者分类：男士，女士，儿童
 *
 * @author Mark sunlightcs@gmail.com
 * @since 1.0.0 2023-08-09
 */
@Service
public class TConsumerServiceImpl extends CrudServiceImpl<TConsumerDao, TConsumerEntity, TConsumerDTO> implements TConsumerService {

    @Override
    public QueryWrapper<TConsumerEntity> getWrapper(Map<String, Object> params){
        Long id = (Long)params.get("id");
        QueryWrapper<TConsumerEntity> wrapper = new QueryWrapper<>();
        wrapper.eq(Objects.nonNull(id), "id", id);
        wrapper.orderByAsc("sort");
        return wrapper;
    }


    @Override
    public List<TConsumerEntity> selectList(Map<String, Object> params){
        List<TConsumerEntity> entityList = baseDao.selectList(getWrapper(params));
        return ConvertUtils.sourceToTarget(entityList, TConsumerEntity .class);
    }




}